var app = getApp();
Component({
  data: {
    selected: '0',
    index:'0',
    color: "#7A7E83", // 颜色
    selectedColor: "#1E70E1", // 被选中颜色
    list: [   {
        "selectedIconPath": "../pages/images/First_Select.png",
        "iconPath": "../pages/images/First.png",
        "pagePath": "/pages/First/First",
        "text": "首页"
    },
    {
        "selectedIconPath": "../pages/images/Shop_Select.png",
        "iconPath": "../pages/images/Shop.png",
        "pagePath": "/pages/Shop/Shop",
        "text": "全部分类"
    },
    {
        "selectedIconPath": "../pages/images/Order_Select.png",
        "iconPath": "../pages/images/Order.png",
        "pagePath": "/pages/Order/Order",
        "text": "订单"
    },
    {
        "selectedIconPath": "../pages/images/Myself_Select.png",
        "iconPath": "../pages/images/Myself.png",
        "pagePath": "/pages/Myself/Myself",
        "text": "我的"
    }
    ]
  },
  attached() {},
  methods: {
    switchTab(e) {
      var url = e.currentTarget.dataset.path
      var index=e.currentTarget.dataset
      app.globalData.selectedIndex =e.currentTarget.dataset.index
      this.setData({
        selected: e.currentTarget.dataset.index
      })
      // 根据index判断，发布是渲染的时候是没有url的
      if (url) {
        wx.switchTab({
          url
        })
      }     
    }
  }
})